package com.wan.data.resource;

import com.wan.IKit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wwh
 * @date 2022/7/5 21:04
 */
public class ResourceModelKit extends IKit {
    private static final Logger logger = LoggerFactory.getLogger(ResourceModelKit.class);
    private static final String ROOT_PATH_KEY = "root_path";
    private static final String MODEL_SCAN_KEY = "model_scan";

    @Override
    public void init() {
        String rootPath = this.groupSetting.get(ROOT_PATH_KEY);
        String modelScan = this.groupSetting.get(MODEL_SCAN_KEY);
        if(rootPath != null && modelScan != null){
            try {
                ModelManager.load(rootPath,modelScan);
            } catch (Exception exception) {
                throw new RuntimeException(exception);
            }
            return;
        }
        logger.warn("配置表加载失败，未配置参数->{},{}",ROOT_PATH_KEY,MODEL_SCAN_KEY);
    }

    @Override
    public void shutdown() {

    }
}
